package com.taikang.hmp.hbusiness.diabetes.measure.report.action.intface;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.taikang.hmp.frame.common.TKException;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.datastructre.support.ResponseDto;
import com.taikang.hmp.frame.common.web.action.BaseAction;
import com.taikang.hmp.hbusiness.diabetes.measure.guide.action.intface.GuideAction;
import com.taikang.hmp.hbusiness.diabetes.measure.report.service.IReportService;

/** 
 * 报告
 * author:qrp
 * time:2015年12月14日 下午2:27:09
 */
public class ReportAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	private static Logger logger = LoggerFactory.getLogger(ReportAction.class);
	
	private IReportService reportService;
	
	public IReportService getReportService() {
		return reportService;
	}
	public void setReportService(IReportService reportService) {
		this.reportService = reportService;
	}
	public String executeAction() {
		if ("getReportList".equals(requestDto.getMethod())) { 
			logger.info("--【获取健康报告列表】: method getReportList --");
			return getReportList();
		}else if ("setReportState".equals(requestDto.getMethod())) {
			logger.info("--【设置健康报告状态】: method getReportState --");
			return setReportState();
		}else if ("getReportCount".equals(requestDto.getMethod())) {
			logger.info("--【获取健康报告未读数量】: method getReportCount --");
			return getReportCount();
		} else {
			logger.info("executeAction 里没有配置"+ requestDto.getMethod() +"方法!");
			throw new TKException("no support method:" + requestDto.getMethod());
		}
	}
	
	/**
	 * 获取健康报告列表
	 * @return
	 */
	public String getReportList(){
		ResponseDto responseDto = new ResponseDto();
		//获取参数
	    Dto paramDto = requestDto.getRequestlist().get(0);
	    paramDto = super.appendRequestBase(paramDto, requestDto);
	    
	    List<Dto> result = reportService.getReportList(paramDto);	
	    Dto resultDto = new BaseDto();
		resultDto.put("resultlist", result);
		responseDto.pushResultDto(resultDto);
		//
		super.setDataMap(responseDto);
		return SUCCESS;
	}
	/**
	 * 设置健康报告状态
	 * @return
	 */
	public String setReportState(){
		ResponseDto responseDto = new ResponseDto();	
		//获取参数
		Dto paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		
		reportService.setReportState(paramDto);

		super.setDataMap(responseDto);
		return SUCCESS;
	}
	/**
	 * 获取提醒列表，返回当日需提醒的未读信息数量
	 * @return
	 */
	public String getReportCount(){
		
		ResponseDto responseDto = new ResponseDto();
		
		//获取参数
		Dto paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		//
		int reportCount = reportService.getReportCount(paramDto);
		Dto resultDto = new BaseDto();
		resultDto.put("result", reportCount);
		responseDto.pushResultDto(resultDto);
		//
		super.setDataMap(responseDto);
		return SUCCESS;
	}

}
